package general;

public class Utils
{
    /**
     * Finds closest greater or equal power of 2.
     * @param value
     * @return
     */
    public static int closestHigherPower2(int value)
    {
        if(value == 0)
            return 1;
        
        int highestBit = 0;
        while((value >> highestBit) > 1)
        {
            highestBit++;
        }
        
        if((1 << highestBit) == value)
        {
            return value;
        }
        else
        {
            return 1 << (highestBit + 1);
        }
    }  
}
